package com.ityedao.IO序列化流;

import java.io.FileOutputStream;
import java.io.ObjectOutputStream;

public class ObjectOutputStreamTest {
    public static void main(String[] args) {
        try (
                // 2、创建一个对象字节输出流包装原始的字节 输出流
                ObjectOutputStream oos = new
                        ObjectOutputStream(
                                new FileOutputStream("src/IO流-序列化流.txt"))
        ) {
            // 1、创建一个Java对象
            User u = new User("admin", "张三", "666sdfda", 32);
            oos.writeObject(u);
            System.out.println("序列化成功！");
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
